package neptune.web.server.operations;

import it.robertobifulco.ias.IncorrectParamsException;
import it.robertobifulco.ias.Operation;
import neptune.manager.model.cluster.PhysicalNode;
import neptune.web.client.model.cluster.SerializablePhysicalNode;
import neptune.web.server.ApplicationManager;
import neptune.web.server.services.SerializationHelper;

/**
 * 
 * @author Luigi Lorenzo Arpino [luigiarpino@yahoo.it]
 *
 */
public class AddPhysicalMachine implements Operation
{
	public static String ID = "AddPhysicalMachine";

	public Object[] execute(Object[] args) throws IncorrectParamsException,
			Exception
	{
		SerializablePhysicalNode serializablePhysicalNode = (SerializablePhysicalNode) args[0];
		PhysicalNode physicalNode = SerializationHelper
				.toPhysicalNode(serializablePhysicalNode);
		ApplicationManager.getApplicationManager().getNeptuneManager()
				.addPhysicalMachine(physicalNode);
		return null;
	}

	public String getDescription() {
		return "Add a physical machine from the cluster";
	}

	public String getID() {
		return ID;
	}

}
